home *** CD-ROM | disk | FTP | other *** search
- package javax.crypto;
-
- import java.security.InvalidAlgorithmParameterException;
- import java.security.InvalidKeyException;
- import java.security.Key;
- import java.security.NoSuchAlgorithmException;
- import java.security.NoSuchProviderException;
- import java.security.Provider;
- import java.security.ProviderException;
- import java.security.SecureRandom;
- import java.security.spec.AlgorithmParameterSpec;
- import java.util.Iterator;
- import java.util.List;
- import sun.security.jca.GetInstance;
- import sun.security.util.Debug;
-
- public class KeyAgreement {
- // $FF: renamed from: a sun.security.util.Debug
- private static final Debug field_0 = Debug.getInstance("jca", "KeyAgreement");
- // $FF: renamed from: b java.security.Provider
- private Provider field_1;
- // $FF: renamed from: c javax.crypto.KeyAgreementSpi
- private KeyAgreementSpi field_2;
- // $FF: renamed from: d java.lang.String
- private final String field_3;
- // $FF: renamed from: e java.security.Provider.Service
- private Provider.Service field_4;
- // $FF: renamed from: f java.util.Iterator
- private Iterator field_5;
- // $FF: renamed from: g java.lang.Object
- private final Object field_6;
- // $FF: renamed from: h int
- private static int field_7 = 10;
- // $FF: renamed from: i int
- private static final int field_8 = 1;
- // $FF: renamed from: j int
- private static final int field_9 = 2;
-
- protected KeyAgreement(KeyAgreementSpi var1, Provider var2, String var3) {
- this.field_2 = var1;
- this.field_1 = var2;
- this.field_3 = var3;
- this.field_6 = null;
- }
-
- private KeyAgreement(Provider.Service var1, Iterator var2, String var3) {
- this.field_4 = var1;
- this.field_5 = var2;
- this.field_3 = var3;
- this.field_6 = new Object();
- }
-
- public final String getAlgorithm() {
- return this.field_3;
- }
-
- public static final KeyAgreement getInstance(String var0) throws NoSuchAlgorithmException {
- List var1 = GetInstance.getServices("KeyAgreement", var0);
- Iterator var2 = var1.iterator();
-
- while(var2.hasNext()) {
- Provider.Service var3 = (Provider.Service)var2.next();
- if (SunJCE_b.b(var3.getProvider())) {
- return new KeyAgreement(var3, var2, var0);
- }
- }
-
- throw new NoSuchAlgorithmException("Algorithm " + var0 + " not available");
- }
-
- public static final KeyAgreement getInstance(String var0, String var1) throws NoSuchAlgorithmException, NoSuchProviderException {
- GetInstance.Instance var2 = SunJCE_b.a("KeyAgreement", KeyAgreementSpi.class, var0, var1);
- return new KeyAgreement((KeyAgreementSpi)var2.impl, var2.provider, var0);
- }
-
- public static final KeyAgreement getInstance(String var0, Provider var1) throws NoSuchAlgorithmException {
- GetInstance.Instance var2 = SunJCE_b.a("KeyAgreement", KeyAgreementSpi.class, var0, var1);
- return new KeyAgreement((KeyAgreementSpi)var2.impl, var2.provider, var0);
- }
-
- // $FF: renamed from: a () void
- void method_0() {
- if (this.field_2 == null) {
- synchronized(this.field_6) {
- if (this.field_2 == null) {
- if (field_0 != null) {
- int var2 = --field_7;
- if (var2 >= 0) {
- field_0.println("KeyAgreement.init() not first method called, disabling delayed provider selection");
- if (var2 == 0) {
- field_0.println("Further warnings of this type will be suppressed");
- }
-
- (new Exception("Call trace")).printStackTrace();
- }
- }
-
- Exception var8 = null;
-
- while(this.field_4 != null || this.field_5.hasNext()) {
- Provider.Service var3;
- if (this.field_4 != null) {
- var3 = this.field_4;
- this.field_4 = null;
- } else {
- var3 = (Provider.Service)this.field_5.next();
- }
-
- if (SunJCE_b.b(var3.getProvider())) {
- try {
- Object var4 = var3.newInstance((Object)null);
- if (var4 instanceof KeyAgreementSpi) {
- this.field_2 = (KeyAgreementSpi)var4;
- this.field_1 = var3.getProvider();
- this.field_4 = null;
- this.field_5 = null;
- return;
- }
- } catch (Exception var6) {
- var8 = var6;
- }
- }
- }
-
- ProviderException var9 = new ProviderException("Could not construct KeyAgreementSpi instance");
- if (var8 != null) {
- var9.initCause(var8);
- }
-
- throw var9;
- }
- }
- }
- }
-
- // $FF: renamed from: a (javax.crypto.KeyAgreementSpi, int, java.security.Key, java.security.spec.AlgorithmParameterSpec, java.security.SecureRandom) void
- private void method_1(KeyAgreementSpi var1, int var2, Key var3, AlgorithmParameterSpec var4, SecureRandom var5) throws InvalidKeyException, InvalidAlgorithmParameterException {
- if (var2 == 1) {
- var1.engineInit(var3, var5);
- } else {
- var1.engineInit(var3, var4, var5);
- }
-
- }
-
- // $FF: renamed from: a (int, java.security.Key, java.security.spec.AlgorithmParameterSpec, java.security.SecureRandom) void
- private void method_2(int var1, Key var2, AlgorithmParameterSpec var3, SecureRandom var4) throws InvalidKeyException, InvalidAlgorithmParameterException {
- synchronized(this.field_6) {
- if (this.field_2 != null) {
- this.method_1(this.field_2, var1, var2, var3, var4);
- } else {
- Exception var6 = null;
-
- while(this.field_4 != null || this.field_5.hasNext()) {
- Provider.Service var7;
- if (this.field_4 != null) {
- var7 = this.field_4;
- this.field_4 = null;
- } else {
- var7 = (Provider.Service)this.field_5.next();
- }
-
- if (var7.supportsParameter(var2) && SunJCE_b.b(var7.getProvider())) {
- try {
- KeyAgreementSpi var8 = (KeyAgreementSpi)var7.newInstance((Object)null);
- this.method_1(var8, var1, var2, var3, var4);
- this.field_1 = var7.getProvider();
- this.field_2 = var8;
- this.field_4 = null;
- this.field_5 = null;
- return;
- } catch (Exception var10) {
- if (var6 == null) {
- var6 = var10;
- }
- }
- }
- }
-
- if (var6 instanceof InvalidKeyException) {
- throw (InvalidKeyException)var6;
- } else if (var6 instanceof InvalidAlgorithmParameterException) {
- throw (InvalidAlgorithmParameterException)var6;
- } else if (var6 instanceof RuntimeException) {
- throw (RuntimeException)var6;
- } else {
- String var12 = var2 != null ? var2.getClass().getName() : "(null)";
- throw new InvalidKeyException("No installed provider supports this key: " + var12, var6);
- }
- }
- }
- }
-
- public final Provider getProvider() {
- this.method_0();
- return this.field_1;
- }
-
- public final void init(Key var1) throws InvalidKeyException {
- this.init(var1, SunJCE_b.b);
- }
-
- public final void init(Key var1, SecureRandom var2) throws InvalidKeyException {
- if (this.field_2 != null) {
- this.field_2.engineInit(var1, var2);
- } else {
- try {
- this.method_2(1, var1, (AlgorithmParameterSpec)null, var2);
- } catch (InvalidAlgorithmParameterException var4) {
- throw new InvalidKeyException(var4);
- }
- }
-
- }
-
- public final void init(Key var1, AlgorithmParameterSpec var2) throws InvalidKeyException, InvalidAlgorithmParameterException {
- this.init(var1, var2, SunJCE_b.b);
- }
-
- public final void init(Key var1, AlgorithmParameterSpec var2, SecureRandom var3) throws InvalidKeyException, InvalidAlgorithmParameterException {
- if (this.field_2 != null) {
- this.field_2.engineInit(var1, var2, var3);
- } else {
- this.method_2(2, var1, var2, var3);
- }
-
- }
-
- public final Key doPhase(Key var1, boolean var2) throws InvalidKeyException, IllegalStateException {
- this.method_0();
- return this.field_2.engineDoPhase(var1, var2);
- }
-
- public final byte[] generateSecret() throws IllegalStateException {
- this.method_0();
- return this.field_2.engineGenerateSecret();
- }
-
- public final int generateSecret(byte[] var1, int var2) throws IllegalStateException, ShortBufferException {
- this.method_0();
- return this.field_2.engineGenerateSecret(var1, var2);
- }
-
- public final SecretKey generateSecret(String var1) throws IllegalStateException, NoSuchAlgorithmException, InvalidKeyException {
- this.method_0();
- return this.field_2.engineGenerateSecret(var1);
- }
- }
-